package structuralpattern.apapter;

/**
 * media适配器
 *
 * @author seer
 * @date 2018/2/7 14:43
 */
public class MediaAdapter implements MediaPlayer {
    AdvanceMediaPlayer advanceMediaPlayer;

    public MediaAdapter(String audioType) {
        if ("vlc".equalsIgnoreCase(audioType)) {
            advanceMediaPlayer = new VlcPlayer();
            return;
        }
        if ("video".equalsIgnoreCase(audioType)) {
            advanceMediaPlayer = new VideoPlayer();
        }
    }

    @Override
    public void play(String audioType, String fileName) {
        if ("vlc".equalsIgnoreCase(audioType)) {
            advanceMediaPlayer.playVlc(fileName);
        }
        if ("video".equalsIgnoreCase(audioType)) {
            advanceMediaPlayer.playVideo(fileName);
        }
    }
}
